package business.command.product
{
	import business.event.product.AddProductToDatabaseEvent;
	import business.service.delegate.ProductAMDelegate;
	
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	import mx.controls.Alert;
	import mx.rpc.IResponder;
	
	import valueObjects.Product;
	
	public class AddProductToDatabaseCommand implements ICommand, IResponder
	{
		public function AddProductToDatabaseCommand()
		{
		}
		public function execute(event:CairngormEvent):void {
			addedProduct = (event as AddProductToDatabaseEvent).addedProduct;
			var productAM:ProductAMDelegate= new ProductAMDelegate(this);
			productAM.addProductToDatabase(addedProduct);
		}
		public function result(result:Object):void {
			var returnResult:Boolean = false;
			returnResult = result.result as Boolean;
			if(returnResult){
				Alert.show("add product to database successfully"); 
			}	
		}
		public function fault(info:Object):void {
		
		}
		private var addedProduct:Product;
		

	}
}